import {useRouter, useRoute} from 'vue-router'
import {useLocaleStore} from '../store/locales.js'

const router = useRouter()

export const UTILS_Tool = () => {
  const router = useRouter()
  const route = useRoute()

  const routerLink = (url, extraParams = {}) => {
    // const useLocale = useLocaleStore()
    router.push({
      path: url,
      query: {
        // language: useLocale.locale === 'en' ? 2 : 1,
        ...extraParams
      }
    })
  }
  return {routerLink}
}

// 获取路由上上面的参数
export const getQueryVariable = () => {
  let href = window.location.href
  let query = href.substring(href.indexOf('?') + 1);
  let vars = query.split("&");
  let obj = {}
  for (var i = 0; i < vars.length; i++) {
    let pair = vars[i].split("=");
    obj[pair[0]] = pair[1]
  }
  return obj;
}
